/**
 * Copyright ©2016-2020 northkingbpo Corporation, All Rights Reserved
 * http://www.northkingbpo.net/
 */
package profile.hujia.commonmultithread.thread;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * class info
 *
 * @author hujia
 * @date 2018/11/23 10:11
 */
public class AtomicIncrement implements Runnable {

    private static AtomicInteger number;
    private final CountDownLatch count;

    public AtomicIncrement(CountDownLatch count) {
        number = new AtomicInteger(0);
        this.count = count;
    }

    @Override
    public void run() {
        for (int j = 0; j < 1000; j++) {
            number.incrementAndGet();
            System.out.println(Thread.currentThread().getName() + ":the number is " + number);
        }
        count.countDown();
    }
}
